<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>驾校信息查看</title>
    <link href="../../layui/css/layui.css" rel="stylesheet">
    <link href="../../static/css/style.css" rel="stylesheet">
    <script src="../../static/js/jquery.min.js"></script>
    <script src="../../static/js/jquery.cookie.js"></script>
    <script src="../../layui/layui.js"></script>
    <script src="../../static/js/base.js"></script>
    <script src="../../static/js/ax.js"></script>
    <script src="../../static/js/avalon.js"></script>
    <!--[if lt IE 9]>
    <script src="../../static/js/html5.js"></script>
    <script src="../../static/js/respond.js"></script>
    <![endif]-->

</head>
<body class="bg_w">

<div class="content-wrap" ms-controller="test2">
    <h3 class="title_li">驾校信息</h3>
    <div class="layui-row">
        <div class="layui-col-sm12">
            <table class="layui-table">
                <tbody>
                <tr>
                    <td class="bg_h">驾校区域</td>
                    <td ms-text="@driverinfo.region">重庆市渝北区</td>
                    <td class="bg_h">所属管辖</td>
                    <td ms-text="@driverinfo.divisionName"></td>
                    <td class="bg_h">驾校图片</td>
                    <td><a :click="seeimg()" :if="@imginfo" style="color: #1E9FFF;">查看</a></td>
                </tr>
                <tr>
                    <td class="bg_h">驾校代码</td>
                    <td ms-text="@driverinfo.code">001</td>
                    <td class="bg_h">驾校名称：</td>
                    <td ms-text="@driverinfo.name"></td>
                    <td class="bg_h">驾校地址</td>
                    <td ms-text="@driverinfo.address"></td>
                </tr>

                <tr>
                    <td class="bg_h">驾校联系人</td>
                    <td ms-text="@driverinfo.contacts"></td>
                    <td class="bg_h">联系人电话</td>
                    <td ms-text="@driverinfo.mobile"></td>
                    <td class="bg_h"></td>
                    <td></td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div :if="@branch">
        <h3 class="title_li">驾校所属分校信息<span class="red">共计{{@branchleng}}个</span></h3>
        <div class="layui-row">
            <div class="layui-col-xs12" style="max-height: 248px; overflow: auto;">
                <table class="layui-table">
                    <thead >
                    <tr>
                        <th>序号</th>
                        <th>分校名称</th>
                        <th>分校地址</th>
                        <th>分校联系人</th>
                        <th>分校联系电话</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ms-for="($index, el) in @branchlist">
                        <td>{{$index+1}}</td>
                        <td>{{el.name}}</td>
                        <td>{{el.address}}</td>
                        <td>{{el.contacts}}</td>
                        <td>{{el.mobile}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div :if="@register">
        <h3 class="title_li">驾校所属报名点信息<span class="red">共计{{@registerleng}}个</span></h3>
        <div class="layui-row">
            <div class="layui-col-xs12" style="max-height: 248px; overflow: auto;">
                <table class="layui-table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>报名点名称</th>
                        <th>报名点地址</th>
                        <th>报名点联系人</th>
                        <th>报名点联系电话</th>
                    </tr>
                    </thead>
                    <tbody style="max-height: 200px; overflow: auto;">
                    <tr ms-for="($index, el) in @registerlist">
                        <td>{{$index+1}}</td>
                        <td>{{el.name}}</td>
                        <td>{{el.address}}</td>
                        <td>{{el.contacts}}</td>
                        <td>{{el.mobile}}</td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>





    <div class="layui-form-item layui-col-space10">
        <div class="layui-input-block">
            <button id="btnClose" type="reset" class="layui-btn layui-btn-primary btn-left">关闭</button>
        </div>
    </div>


</div>


</body>

<script>

    var vm = avalon.define({
        $id:'test2',
        driverinfo:{},
        branch:false,
        register:false,
        imgarry:{},
        imginfo:false,
        branchlist:[],
        branchleng:0,
        registerlist:[],
        registerleng:0,
        //获取所有详情
        getinfo:function () {
            var data={"id":getQueryString("id")}
            ax.post({
                type: 'POST',
                url: schoolWebUrl+"/api/gather/info",
                contentType: "application/x-www-form-urlencoded",
                data: data,
                success: function (res) {
                    console.log(res.data)
                    if(res.code==0){
                         if(res.data.gatherSchoolVo.pics===''){
                             vm.imginfo=false;
                         }else{
                             vm.imginfo=true;
                         }

                        vm.driverinfo=res.data.gatherSchoolVo;

                            var imgs=res.data.gatherSchoolVo.pics.split(',');

                            var imgsdata={
                                "title": "", //相册标题
                                "id": 123, //相册id
                                "start": 0, //初始显示的图片序号，默认0
                                "data": [   //相册包含的图片，数组格式
                                ]
                            }

                            for(var i in imgs){
                                var imglist={
                                    "alt": "驾校图片",
                                    "pid": 666,
                                    "src": fileShowUrl+'?id='+imgs[i],
                                    "thumb": fileShowUrl+'?id='+imgs[i]
                                }
                                imgsdata.data.push(imglist);

                            }
                            vm.imglist=imgsdata;


                        if(JSON.stringify(res.data.branchList)==='[]'){
                           vm.branch=false;
                        }else {
                            vm.branch=true;
                            vm.branchlist=res.data.branchList;
                            vm.branchleng=res.data.branchList.length;
                            console.log(vm.branchlist)
                        }
                        if(JSON.stringify(res.data.registerlist)==='[]'){
                           vm.register=false;
                        }else {
                            vm.register=true;
                            vm.registerlist=res.data.registerlist;
                            vm.registerleng=res.data.registerlist.length;
                        }
                    }

                },
                error: function (request) {
                    parent.layer.msg("系统错误，联系管理员");
                }
            });
        },
        //查看图片
        seeimg:function () {
            layer.photos({
                photos: vm.imglist //格式见API文档手册页
                ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
            });
        },

    })
    vm.$watch('onReady', function () {
        //获取省市区
        this.getinfo();

    });

    layui.use('table', function(){


    });
    //关闭弹框

    $('#btnClose').on("click", function () {
        parent.layer.close(parent.layer.getFrameIndex(window.name));
    });



</script>
</html>